<?php
/**
 *章
 */
class ChapterServer {
	public function pagingBySearch($where="",$order='',$numberEachPage = 10){
		$count = HttpDaoManager::getChapterDao()->searchNumber($where);
		$page = new Page($count, $numberEachPage);
		$limit[0]= $page->which;
		$limit[1]=$numberEachPage;
		$list = HttpDaoManager::getChapterDao()->searchList($where, $order,$limit);
		$page1= $page->returnPage("?".ClassManager::getToos()->combinationGet('page')."&page=");
		

		$course_id_list = Common::array_value_list($list,'course_id');
		$data['course_pairs'] = array();
		if(!empty($course_id_list)){
			$course_list = HttpDaoManager::getCourseDao()->getDataPairList($course_id_list);
			$data['course_pairs'] =Common::fetchPairOfList('id', 'theme', $course_list);		
		}
		$data['list'] =$list;
		$data['page'] = $page1;
		return $data;
	}
	public function deleteBatchByid($id){
		if (is_array($id)){
			$id = implode(',',$id);
		}
		HttpDaoManager::getChapterDao()->deleteBatchByid($id);
	}
	public function add($data){
		$data['add_time'] = time();
		HttpDaoManager::getChapterDao()->add($data);
	}
	
	public function userGetListByCourseId($courseId){
		$data = array(
			'course_id'=>$courseId,
			'status' => 1
		);
		return  HttpDaoManager::getChapterDao()->searchList($data);
	}
	
	
	public function userGetPairListByCourseId($courseId){
		$data = array(
			'course_id'=>$courseId,
			'status' => 1
		);
		return  HttpDaoManager::getChapterDao()->searchPairList($data);
	}
	
	public function userGet($id){
		$data = array(
			'id'=> $id,
			'status' => 1
		);
		return HttpDaoManager::getChapterDao()->searchList($data);
	}
}
?>